//
//  KDReportListCell.m
//  WangJingApp
//
//  Created by 魏强 on 17/11/11.
//  Copyright © 2017年 KDTech. All rights reserved.
//

#import "KDReportListCell.h"
#import "NSString+KD.h"
@interface KDReportListCell ()
/**
 *  cell底部的view
 */
@property (weak, nonatomic) IBOutlet UIView *underView;
@property (weak, nonatomic) IBOutlet UILabel *titleLb;
@property (weak, nonatomic) IBOutlet UILabel *comeFromLb;
@property (weak, nonatomic) IBOutlet UILabel *timeLb;
@property (weak, nonatomic) IBOutlet UILabel *reporterLb;

/**
 *  上报btn
 */
@property (weak, nonatomic) IBOutlet UIButton *reportBtn;
@property (nonatomic, retain) NSDateFormatter *fmt;
@end
@implementation KDReportListCell
- (NSDateFormatter *)fmt
{
    if (!_fmt) {
        _fmt = [[NSDateFormatter alloc]init];
        _fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];;
        _fmt.dateFormat = @"YYYY-MM-dd HH:mm:ss";
    }
    return _fmt;
}
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId =@"KDReportListCell";
    
    
    KDReportListCell *cell =[tableView dequeueReusableCellWithIdentifier:cellId];
    cell.backgroundColor = BackGroundColor;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.reportBtn.layer.cornerRadius = 3.0f;
    cell.reportBtn.clipsToBounds = YES;
    cell.reportBtn.layer.borderWidth = 0.5;
    cell.reportBtn.layer.borderColor = WQColor(255, 149, 0).CGColor
    ;
    //    [cell.reportBtn setImage:[UIImage imageNamed:@"已上报"] forState:UIControlStateDisabled];
    
    
    return cell;
}
- (void)setModel:(KDReportListCellModel *)model{
    _model = model;
    //    self.collectBtn.selected = model.isCollection;
    
    self.titleLb.attributedText = [NSString praseHtmlStr:model.report_title];
    self.comeFromLb.text = model.website_name;
    NSDateFormatter *fmt = [[NSDateFormatter alloc]init];
    fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
    fmt.dateFormat = @"YYYY-MM-dd HH:mm:ss.S";
    NSDate *date = [fmt dateFromString:model.report_time];
    NSString *dateStr = [self.fmt stringFromDate:date];
    self.timeLb.text = dateStr;
    self.reporterLb.text = model.send_user_name;
//    self.featureBtn.selected = (model.emotionType == -1)?YES:NO;
    
}
/**  上报按钮被点击了 */
- (IBAction)reportBtnClick:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(reportListCell:reportBtnClick:)]) {
        [_delegate reportListCell:self reportBtnClick:sender];
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
